package com.example.myservice;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MybindService extends Service {
    class MyBinder extends Binder{
        public void methodInBinder(){
            Log.v("life","MyBinder 中的 methodInBinder");
            method();
        }
    }
    public void method(){
        Log.v("life","Service 中的 method()");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.v("life","创建服务 onCreate()");
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.v("life","绑定服务 onBind()");
        return new MyBinder();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.v("life","解绑服务  onUnbind()");
        return super.onUnbind(intent);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.v("life","开启服务 onStartCommand()");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.v("life","关闭服务 onDestroy()");
    }
}
